package controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * Controller implementation for log in to the application
 */
@Controller
@RequestMapping("/Login")
public class LoginController {

	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView doGet(HttpServletRequest request, HttpServletResponse response) {
		// test sur le login / mdp
		if (request.getParameter("login").equals(request.getParameter("mdp"))) {
			// redirection sur la page Main
			return new ModelAndView("main");
		} else {
			// Mot de passe faux
			return new ModelAndView("index").addObject("messageError", "You informations are not correct.");
		}
	}
}
